#include "DirectoryEntry.h"

DirectoryEntry::DirectoryEntry(DirectoryEntry* parent, UInt32 entryID, string entryName, DirectoryEntryType entryType, UInt32 firstSectorID, UInt32 length)
{
	this->EntryID(entryID);
	this->EntryName(entryName);
	this->EntryType(entryType);
	this->FirstSectorID(firstSectorID);
	this->Length(length);
	this->_parent = parent;

	if (entryType == Root || entryType == Storage)
	{
		this->Children(new vector<DirectoryEntry*>());
	}
}
DirectoryEntry::~DirectoryEntry()
{
}

void DirectoryEntry::AddChild(DirectoryEntry *entry)
{
	if (this->Children() == NULL)
	{
		this->Children(new vector<DirectoryEntry*>());
	}

	this->Children()->push_back(entry);
}

DirectoryEntry *DirectoryEntry::GetChild(string entryName)
{
	for (int i = 0; i < _children->size(); i++)
	{
		
		if (_children->at(i)->EntryName().compare(entryName) ==0)
		{
			
			//printf("%s \n", _children->at(i)->_entryName);
			return _children->at(i);
		}
	}

	return NULL;
}
